package xyz.coolcsm.security.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import xyz.coolcsm.security.entity.SysUserRole;
/**
 * @author 什锦
 * @since 2021-06-1
 */
@Mapper
@Repository
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {

    @Insert({"<script> " +
            "INSERT INTO `sys_user_role_relation`(`user_id`,`role_id`) VALUES( " +
            "#{userId}," +
            "<if test='roleId!=null'>#{roleId})</if> " +
            "<if test='roleId==null'>2)</if> " +
            "</script>"})
    public void addRole(@Param("userId")Integer userId,@Param("roleId") Integer roleId);
}
